package fuzzyLogic;

import net.sourceforge.jFuzzyLogic.*;

public class FuzzyController {
	 
	 FIS fis;
	
	 public FuzzyController()
	 {
		 String fileName = "src/fuzzyLogic/FUNCTION_STRATEGY.fcl";
	        fis = FIS.load(fileName,true);
	        if( fis == null ) { 
	            System.err.println("Can't load file: '" 
	                                   + fileName + "'");
	            return;
	        }

	        // Show 
	        //fis.chart();
	 }
	 
	 public void setVariavel(String name, double value)
	 {
		 fis.setVariable(name, value);	 
	 }
	 
	 public double getOutput(String output)
	 {
		 return fis.getVariable(output).getLatestDefuzzifiedValue();		 
	 }
	 public void evaluate()
	 {
		 fis.evaluate();
	 }
	 public void printOutputChart(String output)
	 {
		 fis.getVariable(output).chartDefuzzifier(true);
	 }
}
